package o;

import android.content.Context;
import android.text.TextUtils;
import android.text.format.DateUtils;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.fastengine.fastview.startFastappEngine.storage.FastAppPreferences;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import com.huawei.hwid.core.constants.HwAccountConstants;

public final class ayn {
    private static boolean ˊ = false;
    private static boolean ˎ = false;
    private static boolean ˏ = false;
    private static boolean ॱ = false;

    public static void ॱ() {
        awg.ˎ.ˋ("ProtocolCacheManager", "clear.");
        ayj.ˊ().ˏ("stop_service");
        ayj.ˊ().ˏ("is_report_agree_global_protocol_succ");
        ayj.ˊ().ˏ("sign_protocol_time_long");
        ayj.ˊ().ˏ("user_sing_time_offline");
        ayj.ˊ().ˏ("last_query_success_time");
        ayj.ˊ().ˏ("agree_protocol_oobe");
        ayj.ˊ().ˏ("agree_protocol");
        ayj.ˊ().ˏ("agree_online_protocol");
        ayj.ˊ().ˏ("account_service_zone");
        ayj.ˊ().ˏ("language_service_zone");
        ayj.ˊ().ˏ(FastAppPreferences.KEY_AGREEMENT_VERSION);
    }

    public static boolean ˊ() {
        return ayj.ˊ().ˏ("is_report_agree_global_protocol_succ", true);
    }

    public static void ˊ(boolean z) {
        ayj.ˊ().ˎ("is_report_agree_global_protocol_succ", z);
    }

    public static void ˎ(long j) {
        ayj.ˊ().ˋ("sign_protocol_time_long", j);
    }

    public static String ˏ() {
        Context ˋ = ContentManager.getInstant().getContext();
        String str = "";
        long ˎ = ayj.ˊ().ˎ("sign_protocol_time_long", 0);
        if (ˎ != 0) {
            return DateUtils.formatDateTime(ˋ, ˎ, 131092);
        }
        return str;
    }

    public static boolean ˎ() {
        return Math.abs(System.currentTimeMillis() - ayj.ˊ().ˎ("last_query_success_time", 0)) > 259200000;
    }

    public static void ˋ() {
        ayj.ˊ().ˋ("last_query_success_time", System.currentTimeMillis());
    }

    @NonNull
    public static String ʽ() {
        return bkz.ˊ(ayj.ˊ().ˎ("account_service_zone", ""));
    }

    @NonNull
    public static String ʼ() {
        return bkz.ˊ(ayj.ˊ().ˎ("language_service_zone", ""));
    }

    public static boolean ʻ() {
        String ˎ = ayj.ˊ().ˎ("agree_online_protocol", "");
        String userId = UserSession.getInstance().getUserId();
        String ˊ = ays.ˊ();
        userId = eux.ॱ(userId + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + ˊ);
        boolean z = userId != null && userId.equalsIgnoreCase(ˎ);
        if (!(ˎ && z == ॱ)) {
            awg.ˎ.ˋ("ProtocolCacheManager", "isSignedForUser, country: " + ˊ + ", isSigned: " + z);
            ˎ = true;
            ॱ = z;
        }
        return z;
    }

    public static boolean ᐝ() {
        boolean ʻ = ʻ();
        if (!ʻ) {
            return ʻ;
        }
        if (Math.abs(System.currentTimeMillis() - ayj.ˊ().ˎ("user_sing_time_offline", 0)) <= HwAccountConstants.CHECK_DURATION) {
            return ʻ;
        }
        awg.ˎ.ˋ("ProtocolCacheManager", "isSignedForUserCheckSignTime, isSigned: " + false);
        return false;
    }

    public static void ˏ(String str, boolean z) {
        awg.ˎ.ˋ("ProtocolCacheManager", "setSignedForUser, country: " + str + ", isSigned: " + z);
        if (z) {
            ayj.ˊ().ˏ("stop_service");
            ayj.ˊ().ˋ("agree_online_protocol", eux.ॱ(UserSession.getInstance().getUserId() + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + str));
            ayj.ˊ().ˋ("account_service_zone", str);
            ayj.ˊ().ˋ("language_service_zone", axg.ˏ().ॱॱ());
            ayj.ˊ().ˋ("user_sing_time_offline", System.currentTimeMillis());
            return;
        }
        ayj.ˊ().ˋ("agree_online_protocol", "");
    }

    public static boolean ॱॱ() {
        boolean z = false;
        String ˊॱ = ˊॱ();
        String ˊ = ays.ˊ();
        if (ayj.ˊ().ˏ("agree_protocol", false) && ˊॱ.equalsIgnoreCase(ayj.ˊ().ˎ(FastAppPreferences.KEY_AGREEMENT_VERSION, "")) && ˊ.equalsIgnoreCase(ayj.ˊ().ˎ("account_service_zone", ""))) {
            z = true;
        }
        if (!(ˏ && z == ˊ)) {
            awg.ˎ.ˋ("ProtocolCacheManager", "isSignedForDevice, country: " + ˊ + ", isSigned: " + z + ", agreementVer: " + ˊॱ);
            ˏ = true;
            ˊ = z;
        }
        return z;
    }

    public static void ˎ(String str, boolean z) {
        if (z) {
            ayj.ˊ().ˏ("stop_service");
            ayj.ˊ().ˎ("agree_protocol", z);
            String ˊॱ = ˊॱ();
            ayj.ˊ().ˋ(FastAppPreferences.KEY_AGREEMENT_VERSION, ˊॱ);
            ayj.ˊ().ˋ("account_service_zone", str);
            awg.ˎ.ˋ("ProtocolCacheManager", "setSignedForDevice, country: " + str + ", isSigned: " + z + ", agreementVer: " + ˊॱ);
            return;
        }
        ayj.ˊ().ˎ("agree_protocol_oobe", z);
        ayj.ˊ().ˎ("agree_protocol", z);
        ayj.ˊ().ˋ(FastAppPreferences.KEY_AGREEMENT_VERSION, "");
        ayj.ˊ().ˋ("account_service_zone", "");
        awg.ˎ.ˋ("ProtocolCacheManager", "setSignedForDevice, country: " + str + ", isSigned: " + z);
    }

    public static boolean ˏॱ() {
        boolean z = false;
        String ˊॱ = ˊॱ();
        String ˊ = ays.ˊ();
        if (ayj.ˊ().ˏ("agree_protocol_oobe", false) && ˊॱ.equalsIgnoreCase(ayj.ˊ().ˎ(FastAppPreferences.KEY_AGREEMENT_VERSION, "")) && ˊ.equalsIgnoreCase(ayj.ˊ().ˎ("account_service_zone", ""))) {
            z = true;
        }
        awg.ˎ.ˋ("ProtocolCacheManager", "isSignedForDeviceByOOBE, country: " + ˊ + ", isSigned: " + z + ", agreementVer: " + ˊॱ);
        return z;
    }

    public static void ॱ(String str, boolean z) {
        if (z) {
            ayj.ˊ().ˏ("stop_service");
            ayj.ˊ().ˎ("agree_protocol_oobe", z);
            String ˊॱ = ˊॱ();
            ayj.ˊ().ˋ(FastAppPreferences.KEY_AGREEMENT_VERSION, ˊॱ);
            ayj.ˊ().ˋ("account_service_zone", str);
            awg.ˎ.ˋ("ProtocolCacheManager", "setSignedForDeviceByOOBE, country: " + str + ", isSigned: " + z + ", agreementVer: " + ˊॱ);
            return;
        }
        ayj.ˊ().ˎ("agree_protocol_oobe", z);
        ayj.ˊ().ˋ(FastAppPreferences.KEY_AGREEMENT_VERSION, "");
        ayj.ˊ().ˋ("account_service_zone", "");
        awg.ˎ.ˋ("ProtocolCacheManager", "setSignedForDeviceByOOBE, country: " + str + ", isSigned: " + z);
    }

    @NonNull
    private static String ˊॱ() {
        if (ays.ˎ()) {
            return axg.ˏ().ᐝ();
        }
        return axg.ˏ().ʼ();
    }

    public static void ˎ(@Nullable Integer[] numArr) {
        String ˊ = bks.ˊ(numArr, ",");
        awg.ˎ.ˋ("ProtocolCacheManager", "setUpgradeIds, upgradeIds: " + ˊ);
        ayj.ˊ().ˋ("protocol_upgrade_ids", ˊ);
    }

    @NonNull
    public static int[] ॱˊ() {
        Object ˎ = ayj.ˊ().ˎ("protocol_upgrade_ids", "");
        ayj.ˊ().ˏ("protocol_upgrade_ids");
        awg.ˎ.ˋ("ProtocolCacheManager", "getUpgradeIds, get and remove, upgradeIds: " + ˎ);
        if (!TextUtils.isEmpty(ˎ)) {
            String[] ˎ2 = bkz.ˎ(ˎ.split(","));
            if (ˎ2.length > 0) {
                int[] iArr = new int[ˎ2.length];
                int i = 0;
                while (i < ˎ2.length) {
                    try {
                        iArr[i] = Integer.parseInt(ˎ2[i]);
                        i++;
                    } catch (NumberFormatException e) {
                        awg.ˎ.ˏ("ProtocolCacheManager", "NumberFormatException, upgrade id invalid.");
                    }
                }
                return iArr;
            }
        }
        return new int[0];
    }

    public static void ˋ(boolean z) {
        ayj.ˊ().ˎ("stop_service", z);
    }

    public static boolean ͺ() {
        return ayj.ˊ().ˏ("stop_service", false);
    }
}
